﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LeetCodeProject
{
    public class Solution26
    {
        public int RemoveDuplicates(int[] nums)//双指针法
        {
            int i = 0, j = 0;
            while(i<nums.Length&&j<nums.Length)
            {
                if (nums[j] == nums[i])
                {
                    j++;
                }
                else
                {
                    i++;
                    nums[i] = nums[j];
                    
                }
            }
            return i+1;
        }
    }
}
